-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OTP-1382 GMAP Push notifications for leg transition #275
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify the intent behind origin/destination change? I think what we want to do is to notify observers that someone has departed or arrived on their trip.
src/main/java/org/opentripplanner/middleware/models/TripMonitorNotification.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
Oh, really! I thought I was to check the OTP response for any changes to the traveler's trip and notify them of this. Could I have a couple of use cases just to clarify what is expected please? |
It is simpler than you think it is. Basically, a notification when the traveler leaves the origin or arrives at destination, and when the traveler changes modes (arrives at a bus stop, gets off the bus, gets on/off the bike if there is a bike involved). |
Notifications are for observers who are not traveling with the traveler and their companion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make these changes please:
- convert the departure/arrival change notification into leaving the origin/arriving at destination notifications, and send the notification when the traveler gets to the corresponding location.
- execute mode change notification when approaching the end of a leg where the next leg has a different mode.
src/main/java/org/opentripplanner/middleware/triptracker/TravelerLocator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the logic is getting there. I don't think we need to identify/process a list of notification types (one should be fine). Notifications are for the observers and non-trip-initiators, and there are language tweaks.
src/main/java/org/opentripplanner/middleware/models/LegTransitionNotification.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/models/LegTransitionNotification.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/utils/ItineraryUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTrip.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/triptracker/TravelerLocator.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opentripplanner/middleware/tripmonitor/jobs/CheckMonitoredTripTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/triptracker/TravelerLocator.java
Outdated
Show resolved
Hide resolved
@@ -19,10 +19,10 @@ public enum Message { | |||
ACCEPT_DEPENDENT_EMAIL_SUBJECT, | |||
ACCEPT_DEPENDENT_EMAIL_MANAGE, | |||
ACCEPT_DEPENDENT_ERROR, | |||
ARRIVED_AND_MODE_CHANGE_NOTIFICATION, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say just keep the old name MODE_CHANGE_NOTIFICATION
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you address duplicate notifications still being sent, please?
src/main/java/org/opentripplanner/middleware/models/LegTransitionNotification.java
Show resolved
Hide resolved
} | ||
|
||
/** | ||
* Create locale specific notifications. | ||
* If a traveler is on schedule and on either a walk or transit leg check for possible leg transition notification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant to say "If a traveler is on the route (not deviated)"...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert comma before "check".
} | ||
|
||
/** | ||
* Depending on the traveler's proximity to the start/end of a leg return the appropriate notification type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Insert comma before "return".
|
||
private static Stream<Arguments> createLegTransitionNotificationTestCases() throws Exception { | ||
String travelerName = "Obi-Wan"; | ||
Locale locale = Locale.US; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove locale
as a test parameter (set that in the test itself).
@@ -559,6 +592,9 @@ private void sendNotifications() { | |||
// TODO: better handle below when one of the following fails | |||
if (successEmail || successPush || successSms) { | |||
notificationTimestampMillis = DateTimeUtils.currentTimeMillis(); | |||
// Prevent repeated notifications by saving successfully sent notifications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isAtStartOfLeg(travelerPosition)) { | ||
return DEPARTED_NOTIFICATION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Change the condition so that departing notifications are sent at the beginning of the trip only.
I found one case where I set two coordinates, one close to the end of a leg, and the next one close to the beginning of the next leg, and I got two companion notifications, one for arriving at the end of the previous leg, and one for departing the next leg, which is redundant with the previous one and is thus unneeded noise. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for consistency we leave it as is. The observer would get a notification that the traveler has arrived but not one to tell them they have departed. The next notification would be the traveler arriving at the end of the next leg. Correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I observed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the changes are working and code looks good. The nice-to-have tweak is not blocking.
@@ -4,7 +4,10 @@ ACCEPT_DEPENDENT_EMAIL_LINK_TEXT = Accepter la demande | |||
ACCEPT_DEPENDENT_EMAIL_SUBJECT = Demande d'accompagnateur | |||
ACCEPT_DEPENDENT_EMAIL_MANAGE = G�rez vos pr�f�rences | |||
ACCEPT_DEPENDENT_ERROR = La demande d'accompagnateur n'a pas �t� re�ue. | |||
ARRIVED_NOTIFICATION = TODO %s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binh-dam-ibigroup can you provide the french messages please!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oui ! 36b26af
…b.com/ibi-group/otp-middleware into feature/OTP-1382-notify-major-changes
Checklist
dev
before they can be merged tomaster
)Description
Check for upcoming leg transitions (arrive, departure & mode change) and notify observers.